//
//  UIView+YCExtension.h
//  YCPublicDemo
//
//  Created by zhangxiaoliang on 2017/5/17.
//  Copyright © 2017年 xinhuanwangluo. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "Masonry.h"

typedef enum : NSUInteger {
    BorderTypeTop,
    BorderTypeLeft,
    BorderTypeRight,
    BorderTypeBottom
} BorderType;

#pragma mark - 提示框信息宏定义
//各种状态(无数据，断网等)下的提示信息
#define tipViewTag 3888
#define noDataTipText @"暂无数据"
#define netTipText  @"当前网络不可用,请检查您的网络"
#define buttontitle  @"点击刷新"
typedef void (^tipclick)();


#pragma mark - UIView坐标分类
@interface UIView (YCExtension)

/**
 *  x值
 */
@property (nonatomic,assign) CGFloat x;

/**
 *  y值
 */
@property (nonatomic,assign) CGFloat y;

/**
 *  中点x
 */
@property (nonatomic, assign) CGFloat centerX;

/**
 *  中点Y
 */
@property (nonatomic, assign) CGFloat centerY;
/**
 *  宽度
 */
@property (nonatomic,assign) CGFloat width;
/**
 *  高度
 */
@property (nonatomic,assign) CGFloat height;
/**
 *  尺寸大小
 */
@property (nonatomic,assign) CGSize size;

/**
 *  origin 值
 */
@property (nonatomic,assign) CGPoint origin;


/**
 top
 */
@property (nonatomic, assign) CGFloat top;

/**
 left
 */
@property (nonatomic, assign) CGFloat left;

/**
 right
 */
@property (nonatomic, assign) CGFloat right;

/**
 bottom
 */
@property (nonatomic, assign) CGFloat bottom;



#pragma mark - 提示框分类
//没有数据
-(void)nullTip;
//请求失败
-(void)errorTip:(tipclick)click;
//移除tipView
-(void)removeTipView;


#pragma mark -加载nibView
+ (UINib *)nib;
+ (UINib *)nibWithName:(NSString *)name;
// 在 StoryBoard 或者 XIB 里复用另外一个 XIB
- (void)loadFromNib;
+ (instancetype)loadFromNib;
+ (instancetype)loadFromNib:(NSString *)nibName;
+ (instancetype)loadFromNibWithFrame:(CGRect)frame;



#pragma mark -给视图添加四周边框

- (void)addBorderWithColor:(UIColor *)color size:(CGFloat)size borderTypes:(NSArray *)types;

- (void)addBorderLayerWithColor:(UIColor *)color size:(CGFloat)size borderType:(BorderType)boderType;


+ (UIView *)yc_drawRectWithRoundCorner:(CGFloat)radius borderWidth:(CGFloat)borderWidth backGroundColor:(UIColor*)backGroundColor borderColor:(UIColor*)borderColor;

@end


#pragma mark - 快速设置空间属性和自动布局的分类（包含了UILabel，UIButton，UITableView等）
//MARK:~~~~ UIView (Maker) ~~~~
@interface UIView (Maker)

+ (instancetype)yc_instanceWithSuperView:(UIView *)superView constraint:(void(^)(MASConstraintMaker *make))constraint;

+ (instancetype)yc_instanceWithBackgroundColor:(UIColor *)backgroundColor superView:(UIView *)superView constraint:(void(^)(MASConstraintMaker *make))constraint;

@end

//MARK:~~~~ UILabel (Maker) ~~~
@interface UILabel (Maker)//行数和对齐方式如果需要请单独设置

+ (instancetype)yc_labelWithFontSize:(float)fontSize textColorValue:(uint)textColorValue superView:(UIView *)superView constraint:(void(^)(MASConstraintMaker *make))constraint;

+ (instancetype)yc_labelWithFont:(UIFont *)font textColor:(UIColor *)textColor superView:(UIView *)superView constraint:(void(^)(MASConstraintMaker *make))constraint;


/**
 创建label 并设置属性
 
 @param text text
 @param fontSize systemFontOfSize:fontSize
 @param textColorValue 16进制色值 无alpha 0x555555
 @param backgroundColorValue 16进制色值 无alpha 0x555555
 @param superView superView
 @param constraint constraint
 @return label
 */
+ (instancetype)yc_labelWithText:(NSString *)text fontSize:(float)fontSize textColorValue:(uint)textColorValue backgroundColorValue:(uint)backgroundColorValue superView:(UIView *)superView constraint:(void(^)(MASConstraintMaker *make))constraint;


/**
 创建label 并设置属性
 
 @param text text
 @param font font
 @param textColor textColor
 @param backgroundColor backgroundColor
 @param superView superView
 @param constraint masonry约束
 @return label
 */
+ (instancetype)yc_labelWithText:(NSString *)text font:(UIFont *)font textColor:(UIColor *)textColor backgroundColor:(UIColor *)backgroundColor superView:(UIView *)superView constraint:(void(^)(MASConstraintMaker *make))constraint;


@end

//MARK:~~~~ UIButton (Maker) ~~~
@interface UIButton (Maker)


/**
 创建button
 
 @param title normal状态下title
 @param titleColor normal状态下titleColor
 @param titleFont titleFont
 @param superView superView
 @param constraint constraint
 @return button
 */
+ (instancetype)yc_buttonWithTitle:(NSString *)title titleColor:(UIColor *)titleColor titleFont:(UIFont *)titleFont superView:(UIView *)superView constraint:(void(^)(MASConstraintMaker *make))constraint;

/**
 创建空白的button
 
 @param superView superView
 @param constraint constraint
 @return button
 */
+ (instancetype)yc_buttonWithSuperView:(UIView *)superView constraint:(void(^)(MASConstraintMaker *make))constraint;


/**
 创建有选中图案的button
 
 @param image image
 @param selectImage selectImage
 @param superView superView
 @param constraint constraint
 @return button
 */
+ (instancetype)yc_buttonWithImage:(UIImage *)image selectImage:(UIImage *)selectImage superView:(UIView *)superView constraint:(void(^)(MASConstraintMaker *make))constraint;



@end

//MARK:~~~~ UITableView (Maker) ~~~
@interface UITableView (Maker)<UITableViewDataSource>

/**
 创建tableView 对其三个数据源方法封装 对简单的tableView适用
 
 @param style UITableViewStyle
 @param cellClassOrNibName cell类或者xib名
 @param sectionNumber 组数
 @param rowNumber 行数
 @param cellConfig 设置cell
 @return tableView
 */
+ (instancetype)yc_tableViewWithStyle:(UITableViewStyle)style cellClassOrNibName:(id)cellClassOrNibName sectionNumber:(NSInteger (^)(void))sectionNumber rowNumber:(NSInteger (^)(NSInteger section))rowNumber cellConfig:(void (^)(NSIndexPath *indexPath ,UITableViewCell *cell))cellConfig;

@end



